package com.mc.web;

import java.util.HashSet;
import java.util.List;
import java.util.Set;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;


import com.mc.model.Article;

import com.mc.model.IndexImage;

import com.mc.model.Path;
import com.mc.model.SubMenu;
import com.mc.model.data_download;
import com.mc.model.newsandbulletin;
import com.mc.service.ArticleService;
import com.mc.service.IDataService;

import com.mc.service.MenuService;

import com.mc.service.IIndexImageService;

import com.mc.service.NewsandbulletService;
import com.mc.service.SubMenuService;
import com.mc.utils.PathUtil;
import com.mc.utils.StringUtil;

@Controller
@RequestMapping("/djzc")
public class DjzcAction {

	
	private Path path = null;
	@Autowired NewsandbulletService newsandbulletService;
	@Autowired private IDataService dataService;

	@Autowired private ArticleService articleService;
	//菜单相关持久层
	@Autowired private MenuService menuService;
	@Autowired private SubMenuService subMenuService;

	@Autowired private IIndexImageService indexImageService;

	/**
	 * 
	 * @param modelMap
	 * @return 党建动态的首页
	 */
	@RequestMapping("/djzcindex")
	public String bkpy(ModelMap modelMap)
	{
		//查询新闻和公告
		List<newsandbulletin> djzcnews = newsandbulletService.selectdjzcnews();
		//StringUtil.getInstace().replaceTitle(djzcnews);
		//查询相关文章
		List<Article> articles = articleService.selectByMenuName("党建之窗");
		//查询子菜单名称
		Set<String> subMenuNames = articleService.getSubMenuNames(articles);
		
		
		List<data_download> nab = dataService.selectbyddtype(1,0, 5);
		modelMap.addAttribute("downloadData", nab);
		StringUtil.getInstace().replaceTitle(djzcnews);
		modelMap.addAttribute("news",djzcnews);
		List<newsandbulletin> picnews = newsandbulletService.newsbytype(4);
		modelMap.addAttribute("picnews",picnews);
		List<IndexImage> images = indexImageService.imagesbytype(2);
		modelMap.addAttribute("images",images);
		modelMap.addAttribute("articles",articles);
		modelMap.addAttribute("subMenuNames",subMenuNames);
		
		
		path = PathUtil.setPathParams(new String[]{"PackageName:Djzc","ViewName:djzc","ViewTitle:党建之窗","smenu:djzc","mmenu:djzcindex"});				
		return PathUtil.returnStr(path, modelMap);
	}
}
